import {ANALYSIS_CONFIG_MODULE, MOCK} from "./_prefix";
import {axios} from '../utils/request'

/**
 *  添加配置信息 POST
 * @param {*} payload
 * @returns
 */
export const addAnalysisConfig = payload => {
    const { fileInfoId, userId, configName, chosenColumns} = payload;
    return axios.post(`${ANALYSIS_CONFIG_MODULE}`, {
    // return axios.post(`${MOCK}/analysis/configs`, {
        fileInfoId, userId, configName, chosenColumns
    }).then(res => {
        return res;
    });
}

/**
 * 获取所有配置 GET  传入用户id
 * @param {userId} payload
 * @returns
 */
export const getAnalysisConfig = payload => {
    const {userId} = payload;
    return axios.get(`${ANALYSIS_CONFIG_MODULE}/all/${userId}`).then(res => {
        // return axios.get(`${MOCK}/analysis/configs/all/:userId`).then(res => {
        return res;
    });
}

/**
 * 删除配置
 * @param {*} payload
 * @returns
 */
export const deleteAnalysisConfig = payload => {
    const {configId} = payload;
    return axios.delete(`${ANALYSIS_CONFIG_MODULE}/${configId}`).then(res => {
    // return axios.delete(`${MOCK}/ml/configs/${configId}`).then(res => {
        return res;
    });
}

/**
 * 获取单个个配置 GET
 * @param {*} payload
 * @returns
 */
export const getOneAnalysisConfig = payload => {
    const { configId } = payload;
    return axios.get(`${ANALYSIS_CONFIG_MODULE}/${configId}`).then(res => {
    // return axios.get(`${MOCK}/analysis/configs/${configId}`).then(res => {
        return res;});
}